import request from '../utils/request'

export const getMyRentList = () => {
  return request({
    url: '/user/houses'
  })
}

// 根据关键字去搜索小区
export const getCommunityList = (id, name) => {
  return request({
    url: '/area/community',
    params: {
      id,
      name
    }
  })
}

// 上传房屋图片
export const uploadImage = files => {
  const formData = new FormData()
  files.forEach(item => {
    formData.append('file', item.file)
  })

  return request({
    url: '/houses/image',
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 发布房源
export const publishHouse = data => {
  return request({
    url: '/user/houses',
    method: 'POST',
    data
  })
}
